package com.dzwww.recommend.rule.service.common.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dzwww.recommend.rule.common.po.RuleDispose;
import com.dzwww.recommend.rule.dao.mapper.RuleDisposeMapper;
import com.dzwww.recommend.rule.service.common.RuleDisposeService;
import com.dzwww.recommend.rule.service.base.impl.BaseServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Auto
 * @since 2019-07-23
 */
@Service
public class RuleDisposeServiceImpl extends BaseServiceImpl<RuleDisposeMapper, RuleDispose> implements RuleDisposeService {

	/**
     * 分页查询，模糊查询
     */
    @Override
    public Page<RuleDispose> listPage(Page<RuleDispose> page, String name, Integer type) {
        if(StringUtils.isBlank(name) && type == null){
            Page<RuleDispose> pageResult = (Page<RuleDispose>)super.page(page);
            return pageResult;
        }
        QueryWrapper<RuleDispose> wrapper = new QueryWrapper<>();
        LambdaQueryWrapper<RuleDispose> lambda = wrapper.lambda();
        if(!StringUtils.isBlank(name)){
        	lambda = lambda.like(RuleDispose::getName,name);
        }
        if(type != null){
        	lambda = lambda.eq(RuleDispose::getType,type);
        }
        Page<RuleDispose> pageResultParam = (Page<RuleDispose>)super.page(page, wrapper);
        return pageResultParam;
    }

}
